﻿DELIMITER //

--
--
DROP PROCEDURE IF EXISTS dsZeusPackageInfo
//

-- HU - Rakomány info
-- EN - Package information
--
--
CREATE PROCEDURE dsZeusPackageInfo 
  (_AccessToken INTEGER, _Code VARCHAR(20))
BEGIN
  DECLARE _Rows INTEGER;
  DECLARE _UserID INTEGER;
  DECLARE _Lang VARCHAR(10);

  --
  --
  CALL spAccessTokenCheck(_AccessToken, _UserID, _Lang);
    
  --
  --
  IF NOT EXISTS (SELECT ID FROM ZeusPackage WHERE Code = _Code) THEN

    IF (_Lang = 'HU') THEN
      SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = N'Nincs ilyen rakomány !';
    END IF;

    IF (_Lang = 'EN') THEN
      SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = N'Package not found !';
    END IF;

    IF (_Lang = 'DE') THEN
      SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = N'Keine solche Fracht !';
    END IF;    
  END IF;


  -- HU - Visszaadja ennek a Rakománynak az adatait
  -- EN - Get the package details
  --

  SELECT Code, ArticleCode, ArticleName, CAST(Expired as DATE) Expired, LocationCode, Quantity, UnitCode, '' Notes
    FROM ZeusPackage
   WHERE Code = _Code;
END
//
